<template>
	<div>
		<el-form :inline="true" :model="queryform" style="padding-top: 10px;padding-left: 5px;">
			<el-form-item label="分类" prop="goods_type" label-width="40px">
				<el-select clearable v-model="queryform.goods_type" placeholder="请选择" style="width: 120px;">
					<el-option v-for="item in goods_typedata" :key="item.goods_type" :label="item.goods_type" :value="item.goods_type"></el-option>
				</el-select>
			</el-form-item>
			<el-form-item label="状态" prop="state" label-width="40px">
				<el-select clearable v-model="queryform.state" placeholder="请选择" style="width: 120px;">
					<el-option v-for="item in statedata" :key="item.value" :label="item.label" :value="item.value"></el-option>
				</el-select>
			</el-form-item>
			<el-form-item label="性别" prop="sex" label-width="40px">
				<el-select clearable v-model="queryform.sex" placeholder="请选择" style="width: 120px;">
					<el-option v-for="item in sexdata" :key="item.value" :label="item.label" :value="item.label"></el-option>
				</el-select>
			</el-form-item>
			<el-form-item label="年份" prop="year" label-width="50px">
				<el-date-picker  v-model="queryform.year" type="year" value-format="yyyy" placeholder="选择年" style="width: 120px;"></el-date-picker>
			</el-form-item>
			<el-form-item label="季节" prop="sex" label-width="40px">
				<el-select clearable v-model="queryform.season" placeholder="请选择" style="width: 120px;">
					<el-option v-for="item in seasondata" :key="item.season" :label="item.season" :value="item.season"></el-option>
				</el-select>
			</el-form-item>
			<el-form-item label="查询条件" prop="tempstring" label-width="80px">
				<el-input v-model="queryform.tempstring" style="width: 200px;" placeholder="请输入商品名称/编码/规格"></el-input>
			</el-form-item>
			<br />
			<el-form-item>
				<div style="float: left;">
					<el-button type="primary" @click="querybutton">查询</el-button>
				</div>
			</el-form-item>
			<el-form-item>
				<div style="float: left;margin-left: -10px;">
					<el-button type="primary" @click="addgoodsbutton">新增商品</el-button>
				</div>
			</el-form-item>
			<el-form-item>
				<div style="float: left;margin-left: -10px;">
					<el-button type="primary" @click="deletebutton">删除商品</el-button>
				</div>
			</el-form-item>
			<el-form-item>
				<div style="float: left;margin-left: -10px;">
					<el-button type="primary" @click="updatestatebutton">商品下架</el-button>
				</div>
			</el-form-item>
			<el-form-item>
				<div style="float: left;margin-left: -10px;">
					<el-button type="primary" @click="showbutton">详情</el-button>
				</div>
			</el-form-item>
			<el-form-item>
				<div style="float: left;margin-left: -10px;">
					<a href="http://sjqz.oss-cn-shenzhen.aliyuncs.com/sjqz/%E9%99%84%E4%BB%B6/%E5%95%86%E5%93%81.xlsx">
						<el-button type="primary" >Excel模板下载</el-button>
					</a>
				</div>
			</el-form-item>
			
			<el-form-item>
				<div style="float: left;margin: 0px;padding-top: 2px;">
					<v-import v-if="showInput" :colname-data=colnameData :colName=colName :cmd=importCmd v-on:importResult="importResult" type="string"></v-import>
				</div>
			</el-form-item>
			<el-form-item>
				<div style="float: left;margin-left: -10px;">
					<el-button type="primary" @click="showExport">导出报表</el-button>
				</div>
			</el-form-item>
		</el-form>
		<v-table :chart-data=goodsData :items-data=itemsDate v-on:onEdit="showEdit" v-on:selectionChange="handleSelectionChange"></v-table>
		
		<el-dialog title="新增商品" :visible.sync="addgoodsDialog" :close-on-click-modal="false" style="padding-bottom:0;width:120%;" modal>
			<el-form :model="addForm" label-width="120px" ref="queryform">
				<el-row :gutter="20">
					<el-col :span="10" style="margin-left: -10px;">
						<el-form-item label="商品编码" prop="goods_id" label-width="70px">
							<el-input v-model="addForm.goods_id" auto-complete="off" placeholder="请输入商品编码" ></el-input>
						</el-form-item>
						<el-form-item label="商品名称" prop="goods_name" label-width="70px">
							<el-input v-model="addForm.goods_name" auto-complete="off" placeholder="请输入商品名称" ></el-input>
						</el-form-item>
						<el-form-item label="商品分类" prop="goods_type" label-width="70px">
							<el-select clearable v-model="addForm.goods_type" placeholder="请选择" >
								<el-option v-for="item in goods_typedata" :key="item.goods_type" :label="item.goods_type" :value="item.goods_type"></el-option>
							</el-select>
						</el-form-item>	
						<el-form-item label="状态" prop="state" label-width="40px">
							<el-select clearable v-model="addForm.state" placeholder="请选择" >
								<el-option v-for="item in statedata" :key="item.value" :label="item.label" :value="item.value"></el-option>
							</el-select>
						</el-form-item>	
						<el-form-item label="标签" prop="label" label-width="40px">
							<el-input v-model="addForm.label" auto-complete="off" placeholder="请输入标签" ></el-input>
						</el-form-item>	
						<el-form-item label="性别" prop="sex" label-width="40px">
							<el-select clearable v-model="addForm.sex" placeholder="请选择" style="width: 120px;">
								<el-option v-for="item in sexdata" :key="item.value" :label="item.label" :value="item.label"></el-option>
							</el-select>
						</el-form-item>	
						<el-form-item label="季节" prop="sex" label-width="40px">
							<el-select clearable v-model="addForm.season" placeholder="请选择" >
								<el-option v-for="item in seasondata" :key="item.season" :label="item.season" :value="item.season"></el-option>
							</el-select>
						</el-form-item>
					</el-col>
					<el-col :span="14">
						<el-form-item label="年份" prop="year" >
							<el-date-picker  v-model="addForm.year" type="year" value-format="yyyy" placeholder="选择年" style="width:100%"></el-date-picker>
						</el-form-item>
						<el-form-item label="单价" prop="price">
							<el-input v-model="addForm.price" auto-complete="off" placeholder="请输入单价" ></el-input>
						</el-form-item>
						<el-form-item label="成本" prop="cost">
							<el-input v-model="addForm.cost" auto-complete="off" placeholder="请输入成本" ></el-input>
						</el-form-item>
						<el-form-item label="材料" prop="material">
							<el-input v-model="addForm.material" auto-complete="off" placeholder="请输入材料" ></el-input>
						</el-form-item>
						<el-form-item label="尺码" prop="size_id">
							<el-select clearable v-model="addForm.size_id" placeholder="请选择" >
								<el-option v-for="item in sizeData"  :key="item.size_id" :label="item.size_name" :value="item.size_id"></el-option>
							</el-select>
						</el-form-item>	
						<el-form-item label="颜色" prop="color_id">
							<el-select clearable v-model="addForm.color_id" placeholder="请选择" >
								<el-option v-for="item in colorData"  :key="item.color_id" :label="item.color_name" :value="item.color_id"></el-option>
							</el-select>
						</el-form-item>	
						<el-form-item label="库存" prop="quantity">
							<el-input v-model="addForm.quantity" auto-complete="off" placeholder="请输入库存" ></el-input>
						</el-form-item>	
					</el-col>
				</el-row>
					<el-form-item label='增加图片' prop="">
						<el-upload  class="avatar-uploader" action="" 
									:on-remove="handleRemove" 
									:before-remove="beforeRemove" 
									:file-list="addformd.fileList" 
									:limit='1'
									list-type="picture-card" 
									:show-file-list="showfilelist"
									:on-exceed="handleExceed" 
									:http-request="fnUploadRequest" 
									>
							<i class="el-icon-plus"></i>
						</el-upload>
					</el-form-item>
			</el-form>
			<div slot="footer" class="dialog-footer" style="text-align: center; margin-left:30px;margin-left:80px;">
				<el-button type="primary" @click.native="addSubmit">提交</el-button>
			</div>
		</el-dialog>
		
		 <el-dialog  :title="text" :visible.sync="dialogUpdate" :close-on-click-modal="false"  style="padding-bottom:0;padding-right:5%;width : 120%;">
			<el-form :model="addForm" label-width="80px" ref="addForm"
			style="height:350px;">
				<el-row :gutter="20">
					<el-col :span="12">
						<el-form-item label="商品编码" prop="goods_id">
							<el-input v-model="addForm.goods_id" auto-complete="off" disabled placeholder="请输入商品编码" ></el-input>
						</el-form-item>
						<el-form-item label="商品名称" prop="goods_name">
							<el-input v-model="addForm.goods_name" auto-complete="off" disabled placeholder="请输入年份"></el-input>
						</el-form-item>
						<!-- <el-form-item label="尺码" prop="size_id">
							<el-select clearable v-model="addForm.size_id" placeholder="请选择" style="width: 200px;">
								<el-option v-for="item in sizeData"  :key="item.size_id" :label="item.size_name" :value="item.size_id"></el-option>
							</el-select>
						</el-form-item>	
						<el-form-item label="颜色" prop="color_id">
							<el-select clearable v-model="addForm.color_id" placeholder="请选择" style="width: 200px;">
								<el-option v-for="item in colorData"  :key="item.color_id" :label="item.color_name" :value="item.color_id"></el-option>
							</el-select>
						</el-form-item>	
						<el-form-item label="库存" prop="quantity">
							<el-input v-model="addForm.quantity" auto-complete="off" placeholder="请输入库存" style="width: 200px;"></el-input>
						</el-form-item> -->	
						<el-form-item label="年份" prop="year">
							<el-input v-model="addForm.year" auto-complete="off" placeholder="请输入年份" ></el-input>
						</el-form-item>	
						<el-form-item label="价格" prop="price">
							<el-input v-model="addForm.price" auto-complete="off" placeholder="请输入价格" ></el-input>
						</el-form-item>	
						<el-form-item label="成本" prop="cost">
							<el-input v-model="addForm.cost" auto-complete="off" placeholder="请输入成本" ></el-input>
						</el-form-item>	
						<el-form-item label="材料" prop="material">
							<el-input v-model="addForm.material" auto-complete="off" placeholder="请输入材料" ></el-input>
						</el-form-item>	
					</el-col>
					<el-col :span="12">
						<el-form-item label="季节" prop="season">
							<el-select clearable v-model="addForm.season" placeholder="请选择" >
								<el-option v-for="item in seasondata" :key="item.season" :label="item.season" :value="item.season"></el-option>
							</el-select>
						</el-form-item>	
						<el-form-item label="商品分类" prop="goods_type">
							<el-select clearable v-model="addForm.goods_type" placeholder="请选择" >
								<el-option v-for="item in goods_typedata" :key="item.goods_type" :label="item.goods_type" :value="item.goods_type"></el-option>
							</el-select>
						</el-form-item>	
						<el-form-item label="状态" prop="state">
							<el-select clearable v-model="addForm.state" placeholder="请选择" >
								<el-option v-for="item in statedata" :key="item.value" :label="item.label" :value="item.value"></el-option>
							</el-select>
						</el-form-item>	
						<el-form-item label="标签" prop="label">
							<el-input v-model="addForm.label" auto-complete="off" placeholder="请输入标签" ></el-input>
						</el-form-item>	
						<el-form-item label="性别" prop="sex">
							<el-select clearable v-model="addForm.sex" placeholder="请选择" >
								<el-option v-for="item in sexdata" :key="item.value" :label="item.label" :value="item.label"></el-option>
							</el-select>
						</el-form-item>	
					</el-col>
				</el-row>
			</el-form>
			<div slot="footer" class="dialog-footer" style="text-align: left; margin-left:30px;margin-left:80px;">
				<el-button @click="dialogUpdate = false">取 消</el-button>
				<el-button type="primary" @click="updateButton">确 定</el-button>
			</div>
		</el-dialog>
		
		<el-dialog title="该商品库存" :visible.sync="dialogshow" >
			<el-table :data="goods_stockData" showOverflowTooltip :max-height="tabHeight" style="width: 100%" stripe border tooltip-effect="dark">
				<!--<el-table-column type="selection" width="50" > </el-table-column>-->
				<el-table-column prop="goods_id" label="商品编码" show-overflow-tooltip></el-table-column>
				<el-table-column prop="goods_name" label="商品名称" show-overflow-tooltip></el-table-column>
				<el-table-column prop="size_name" label="尺码名称" show-overflow-tooltip></el-table-column>
				<el-table-column prop="color_name" label="颜色名称" show-overflow-tooltip></el-table-column>
				<el-table-column prop="quantity" label="库存" show-overflow-tooltip></el-table-column>
			</el-table>
		</el-dialog>
	</div>
</template>

<script>
	import axios from 'axios';
	import { fetchList,selectgoods,selectallsize,selectallcolor,updategoods,creategoods,delete_goods,selectstockbyid,selectstockid ,update_state} from '../../api/goods.js';
	import vTable from '../../components/charts/table.vue';
	import OSS from 'ali-oss';
	import { Client } from '../../js/common.js';
	import vImport from '../../components/charts/importExcel.vue';
	export default {
		data() {
			return {
				showInput:true,
				colnameData:['商品编码','商品名称','商品分类','状态','标签','性别','季节','年份','单价','成本','材料','尺码','颜色','库存','图片'],
				colName:['goods_id','goods_name','goods_type','state','label','sex','season','year','price','cost','material','size_id','color_id','quantity','picture'],
				importCmd:'',
				queryform:{
					goods_type:'',
					state:null,
					sex:'',
					year:'',
					season:'',
					tempstring:''
				},
				goods_typedata:[
					{'goods_type':'男上装'},
					{'goods_type':'女上装'},
					{'goods_type':'男下装'},
					{'goods_type':'女下装'},
					{'goods_type':'男套装'},
					{'goods_type':'女套装'},
					{'goods_type':'裙子'},
					{'goods_type':'连衣裙'},
					{'goods_type':'下身裙'},
				],
				sexdata:[
					{'label':'男','value':'1'},
					{'label':'女','value':'2'},
					// {'label':'中性','value':'3'},
				],
				goods_stockData:[],
				seasondata:[
					{'season':'春季'},
					{'season':'夏季'},
					{'season':'秋季'},
					{'season':'冬季'}
				],
				statedata:[
					{label:'上架',value:1},
					{label:'下架',value:0}
				],
			    test:'',
				goodsData:[],
				itemsDate:[
					{prop:'goods_id',label:'商品编码'},
					{prop:'goods_name',label:'商品名称'},
					{prop:'sex',label:'性别'},
					// {prop:'size_name',label:'尺码'},
					// {prop:'color_name',label:'颜色'},
					{prop:'price',label:'价格'},
					{prop:'cost',label:'成本'},
					{prop:'material',label:'材料'},
					// {prop:'quantity',label:'库存'},
					{prop:'year',label:'年份'},
					{prop:'season',label:'季节'},
					{prop:'goods_type',label:'商品分类'},
					{prop:'state',label:'状态'},
					{prop:'label',label:'标签'},
					{prop:'create_time',label:'时间'},
					{prop:'picture',label:'图片'},
				],
				multipleTable:[],
				dialogUpdate:false,
				dialogshow:false,
				text:'',
				addForm:{
					id:'',
					ykey:'',
					goods_id:'',
					goods_name:'',
					size_id:'',
					color_id:'',
					quantity:'',
					goods_type:'',
					state:'',
					label:'',
					sex:'',
					season:'',
					year:'',
					cost:'',
					price:'',
					material:'',
				},
				addformd:{
					delOBJ:[],
					fileList:[]
				},
				fileList:[],
				sizeData:[],
				colorData:[],
				addgoodsDialog:false,
				showfilelist: true,
				tabHeight:500
				
			};
		},
		components:{
		    vTable,
			vImport
		},
		methods:{
			importResult(val){
				this.showInput = false;
				this.$nextTick(function(){
					this.showInput = true;
				})
				if( val === true ){
					// this.submit();
				}
			},
			showbutton(){
				if(this.multipleTable.length == 0){
					this.$notify({title: '信息提示',message: '请选择商品！',type: 'info'});
					return;
				}else if(this.multipleTable.length > 1){
					this.$notify({title: '信息提示',message: '只能选择一个商品！',type: 'info'});
					return;
				}else{
					this.dialogshow = true;
					this.goods_stockData = [];
					// console.log(this.multipleTable[0].goods_id,'this.multipleTable[0].goods_id')
					selectstockid({parameter:this.multipleTable[0].goods_id}).then(response => {
						if(response.code == 0){
							this.goods_stockData = response.data;
						}
						
					})
				}
			},
			querybutton:function(){
				this.goodsData = [];
				selectgoods(this.queryform).then(response => {
					if(response.code ==0 ){
						this.goodsData = response.data;
					}
				    
				})
			},
			updatestatebutton(){
				if(this.multipleTable.length == 0){
					this.$notify({title: '信息提示',message: '请选择要上下架的商品！',type: 'info'});
					return;
				}else if(this.multipleTable.length > 1){
					this.$notify({title: '信息提示',message: '只能选择一个商品！',type: 'info'});
					return;
				}else{
					this.$confirm('是否确定上下架'+this.multipleTable[0].goods_name+'?', '提示', {
						confirmButtonText: '确定',cancelButtonText: '取消',type: 'warning'
					}).then(() => {
						// console.log(indexPath.ckey,'indexPath.ckey');
						let s = null;
						if(this.multipleTable[0].state==0){
							s = 1;
						}else{
							s = 0;
						}
						console.log(this.multipleTable[0].id,s,'151561515')
					update_state({parameter:this.multipleTable[0].parameter1,state:s}).then(() => {
					 	this.$notify({
					 	    title: '成功',
					 	    message: '修改成功',
					 	    type: 'success',
					 	    duration: 2000
					 	  })
					 	this.querybutton();  
					 
					})
					}).catch(() => {
						this.$message({
							type: 'info',message: '已取消修改'
						});
					});
				}
			},
			addSubmit(){
				console.log(this.addForm,'this.addForm')
				if(this.addForm.goods_id == '' || this.addForm.goods_name == '' ||this.addForm.size_id == ''
					 ||this.addForm.color_id == '' ||this.addForm.quantity == '' ||this.addForm.goods_type == '' 
					 || this.addForm.state == '' ||this.addForm.label == '' ||this.addForm.sex == '' 
					 ||this.addForm.season == '' ||this.addForm.year == '' ||this.addForm.cost == ''
					 || this.addForm.price == '' ||this.addForm.material == ''||this.addForm.picture == ''){
					 this.$notify({
					     title: '警告',
					     message: '请填写完整信息',
					     type: 'info'
					   })
					   return ;
				 }
				
				creategoods(this.addForm).then(() => {
				  	this.$notify({
				  	    title: '成功',
				  	    message: '新增商品成功',
				  	    type: 'success',
				  	    duration: 2000
				  	  })
				  	this.querybutton();  
					this.addgoodsDialog = false;
				})
			},
			deletebutton:function(){
				if(this.multipleTable.length == 0){
					this.$notify({title: '信息提示',message: '请选择要删除的商品！',type: 'info'});
					return;
				}else if(this.multipleTable.length > 1){
					this.$notify({title: '信息提示',message: '只能删除一个商品！',type: 'info'});
					return;
				}else{
					this.$confirm('是否确定删除'+this.multipleTable[0].goods_name+'?', '提示', {
						confirmButtonText: '确定',cancelButtonText: '取消',type: 'warning'
					}).then(() => {
						// console.log(indexPath.ckey,'indexPath.ckey');
					delete_goods({id:this.multipleTable[0].id,goods_id:this.multipleTable[0].goods_id}).then(() => {
					
					 	this.$notify({
					 	    title: '成功',
					 	    message: '删除成功',
					 	    type: 'success',
					 	    duration: 2000
					 	  })
					 	this.querybutton();  
					 
					})
					}).catch(() => {
						this.$message({
							type: 'info',message: '已取消删除'
						});
					});
				}
			},
			get_sizeList() {
			  selectallsize().then(response => {
				  if(response.code ==0 ){
				  	this.sizeData = response.data;
				  }
			  })
			},
			get_colorList() {
			  selectallcolor().then(response => {
			    if(response.code ==0 ){
			    	this.colorData = response.data;
			    }
			  })
			},
			get_goodsList() {
				this.goodsData = [];
			  fetchList().then(response => {
			    if(response.code ==0 ){
			    	this.goodsData = response.data;
			    }
			  })
			},
			showEdit:function(index,row){
				this.dialogUpdate = true;
				this.text = '修改';
				this.addForm.id = row.id;
				this.addForm.ykey = row.ykey;
				this.addForm.goods_id = row.goods_id;
				this.addForm.goods_name = row.goods_name;
				this.addForm.size_id = row.size_id;
				this.addForm.color_id = row.color_id;
				this.addForm.quantity = row.quantity;
				this.addForm.goods_type = row.goods_type;
				this.addForm.state = row.state;
				this.addForm.label = row.label;
				this.addForm.sex = row.sex;
				this.addForm.year = row.year;
				this.addForm.season = row.season;
				this.addForm.price = row.price;
				this.addForm.cost = row.cost;
				this.addForm.material = row.material;
				// this.selectRow=row;
			},
			updateButton(){
				updategoods(this.addForm).then(response => {
					if(response.code == 0){
						this.$notify({
						    title: '成功',
						    message: response.msg,
						    type: 'success',
						    duration: 2000
						  })
						this.querybutton();  
					}
				})
				this.dialogUpdate = false;
			},
			handleSelectionChange(val){
				this.multipleTable = val;
			},
			
			addgoodsbutton(){
				this.addForm.id = '';
				this.addForm.ykey = '';
				this.addForm.goods_id = '';
				this.addForm.goods_name = '' ;
				this.addForm.size_id = '';
				this.addForm.color_id = '' ;
				this.addForm.quantity = ''
				this.addForm.goods_type = '' ;
				this.addForm.state = '' ;
				this.addForm.label = '' ;
				this.addForm.sex = '' ;
				this.addForm.season = '' ;
				this.addForm.year = '' ;
				this.addForm.cost = '' ;
				this.addForm.price = '' ;
				this.addForm.material = '';
				this.addForm.picture = '';
				this.addgoodsDialog = true;
			},
			handleRemove(file, fileList) {
				let client = Client.NewOSS();
				try {
					this.addformd.delOBJ = [];
					this.addformd.delOBJ.push(file.pathName);
					for(let i = 0; i < this.addformd.fileList.length; i++) {
						if(this.addformd.fileList[i] == file) {
							this.addformd.fileList.splice(i, 1);
						}
					}
				} catch(e) {
					console.log(e);
				}
			},
			beforeRemove(file, fileList) {
				return this.$confirm(`确定移除 ${ file.name }？`);
			},
			handleExceed(files, fileList) {
				this.$message.warning(`图片类型只能上传9个,视频文件只能上传1个`);
			},
			fnUploadRequest: function(val) {
				let _this = this;
				console.log(val,'val')
				let file = val.file;
				let reader = new FileReader();
				reader.readAsDataURL(file);
				// 文件base64化，以便获知图片原始尺寸
				reader.onload = function(event) {
					let baseData = event.target.result;
					let p = {};
					p.base64 = baseData.split(',')[1];
					p.fileType = baseData.split(';')[0].split(':')[1];
					p.name = file.name;
					let list = file.name.split('.');
					p.extensionName = list[list.length - 1];
					_this.uploadOSS(p);
				};
			},
			uploadOSS(data) {
				let _this = this;
				let base64 = data.base64;
				let fileType = data.fileType;
				let fileName = data.name;
				let blob = this.toBlob(base64, fileType);
				let reader = new FileReader();
				reader.readAsArrayBuffer(blob);
				reader.onload = function(event) {
					// 配置服务器
					let client = Client.NewOSS();
					// 文件名
					let date = new Date();
					let yyyymm = '' + date.getFullYear() + ((date.getMonth() + 1) < 10 ? '0' + (date.getMonth() + 1) : (date.getMonth() + 1));
					let storeAs = 'sjqz/order_picture/' + fileName;
					// arrayBuffer转Buffer
					var buffer = new OSS.Buffer(event.target.result);
					// 上传
					client.put(storeAs, buffer).then(function(result) {
						data.url = result.url;
						_this.addForm.picture = result.url;
						data.pathName = result.name;
						_this.addformd.fileList.push(data);
						console.log(_this.addformd.fileList,"我到这里了")
					}).catch(function(err) {
						console.log(err);
					});
				}
			},
			toBlob: function(urlData, fileType) {
				let bytes = window.atob(urlData),
					n = bytes.length,
					u8arr = new Uint8Array(n);
				while(n--) {
					u8arr[n] = bytes.charCodeAt(n);
				}
				return new Blob([u8arr], {
					type: fileType
				});
			},
			showExport(){
				this.downloadLoading = true
			   require.ensure([], () => {
					const {
						export_json_to_excel
					} = require('../../vendor/Export2Excel')
					const tHeader = ['商品编码','商品名称','性别','价格','成本','材料','年份','季节','商品分类','状态','标签','时间','图片'];
					const filterVal = ['goods_id','goods_name','sex','price','cost','material','year','season','goods_type','state','label','create_time','picture'];
					const list = this.goodsData;
					const _data = this.formatJson(filterVal, list);
					export_json_to_excel(tHeader, _data, '商品表','商品表');
				
				})
			},
			formatJson(filterVal, jsonData) {
				return jsonData.map(v => filterVal.map(j => v[j]))
			},
		},
		created(){
			this.get_sizeList();
			this.get_colorList();
			this.querybutton();
		}
		
	}
</script>

<style>

</style>
